package cn.com.hhrcw.oauth;

import com.alibaba.fastjson.JSONObject;
import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.Get;
import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.callback.OnError;

/**
 * http消息发送服务
 *
 * @author lixingxing
 */
@BaseRequest(baseURL = "${oathHost}")
public interface IOathService {
    /**
     * 授权登陆
     *
     * @param code
     * @param redirectUri
     * @param error
     * @return
     */
    @Get(url = "/oauth2/access_token?client_id=${clientId}&client_secret=${clientSecret}&grant_type=authorization_code")
    JSONObject accessToken(@Query("code") String code, @Query("redirect_uri") String redirectUri, OnError error);

    /**
     * 获取用户信息
     * @param accessToken
     * @return
     */
    @Get(url = "/oauth2/user_info",headers = "Accept: text/html", dataType = "json")
    JSONObject userInfo(@Query("access_token") String accessToken);

}
